package com.mycinema.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mycinema.dao.CategoryDao;
import com.mycinema.dao.MovieDao;
import com.mycinema.entity.Category;
import com.mycinema.service.CategoryService;
@Service
public class CategoryServiceImpl implements CategoryService{
	@Autowired
	private CategoryDao categoryDao;
	@Autowired
	private MovieDao movieDao;
	
	public List<Category> getAll() {
		
		return categoryDao.getAll();
	}

	public Category fetchById(int id) {
		
		return categoryDao.fetchById(id);
	}

	public int addCategory(Category category) {
		
		return categoryDao.addCategory(category);
	}

	public void delete(int id) {
		//先删除改类别的所有电影
		movieDao.deleteByCid(id);
		//删除类别
		categoryDao.delete(id);
		
	}

}
